import '@/scss/reset.scss';
import '@/scss/common.scss';
import '@/css/font-awesome.min.css';
import '@/scss/card.scss';
import '@/scss/select.scss';
import './vpsserver.scss';
import $ from 'jquery';
import '@/js/select';


let btnHref = '/services/server/Order.asp?'
let vpsConfig = [
  {
    productid: 'vps001',
    CPU: 'Intel 5645/E5-2620四核处理器&times;4',
    Memory: '2 GB ECC',
    HardDisk: '60G SAS硬盘+80G SATA(智能备份)',
    HostID: '商务1型VPS',
    vps: 'okay',
    vr_room: '3'
  },
  {
    productid: 'vps002',
    CPU: 'Intel 5645/E5-2620四核处理器&times;4',
    Memory: '3 GB ECC',
    HardDisk: '80G SAS硬盘+100G SATA(智能备份)',
    HostID: '商务2型VPS',
    vps: 'okay',
    vr_room: '3'
  },
  {
    productid: 'vps003',
    CPU: 'Intel 5645/E5-2620四核处理器&times;4',
    Memory: '4 GB ECC',
    HardDisk: '100G SAS硬盘+60G SATA(智能备份)',
    HostID: '商务3型VPS',
    vps: 'okay',
    vr_room: '3'
  },
  {
    productid: 'vps000',
    CPU: 'Intel 5645/E5-2620四核处理器&times;4',
    Memory: '1 GB ECC',
    HardDisk: '40G SAS硬盘+40G SATA(智能备份)',
    HostID: '入门型VPS',
    vps: 'okay',
    vr_room: '3'
  }
]
$('[data-plugin="select"]').on('onSelect', function (e) {
  let room = e.value
  let $priceCol = $(this).next('.price-col')
  $priceCol.find('.item').each(function (i, ele) {
    $(ele)[$(ele).data('value') == room ? 'addClass' : 'removeClass']('show')
  })

  let $btn = $(`#${e.selectName}`)
  let params = ''
  for (let item of vpsConfig) {
    if (item.productid == e.selectName) {
      item.vr_room = e.value
      for (let key in item) {
        key == 'productid' ? params += `${key}=${escape(item[key])}` : params += `&${key}=${escape(item[key])}`
      }
    }
  }
  $btn.attr('href', btnHref + params)
})

